// const baseURL = 'http://localhost:8080/sdic-admin';
const baseURL = 'http://www.ro-tech.cn/sdic-admin';

const timeout = 3000;

function request(url, method, data = {}, contentType, back) {
    $.ajax({
        url: baseURL + url,
        type: method,
        data: data,
        cache: false,
        timeout: timeout,
        contentType: contentType,
        dataType: "json",
        success: function (res) {
            return typeof back == "function" && back(res);
        },
        error: function (error) {
            return typeof back == "function" && back(null);
        }
    });
}

function getAjaxRequst(url, data, callBack) {
    request(url, "GET", data, "application/json;charset=UTF-8", function (res) {
        return typeof callBack == "function" && callBack(res)
    })
}

function postAjaxRequst(url, data, callBack) {
    request(url, "POST", data, "application/json;charset=UTF-8", function (res) {
        return typeof callBack == "function" && callBack(res)
    })
}